<template>
	<!-- <signPreview ></signPreview> -->
	<signPreview v-if="isSign" :applyId="applyIdFromCommit" pageSourceCode="applyShortTable"></signPreview>
	<div
		v-else
		:class="['m-window','applyShortTable-col',{'opts-hidden':isSubmitApplyTable}]"
		v-loading="loading"
		element-loading-text="数据加载中"
	>
		<el-row :gutter="10" class="header-btns-col">
			<el-col :span="2">
				<el-button type="primary" @click="goBack">返回</el-button>
			</el-col>
		</el-row>
		<el-row :gutter="10" class="footer-btns-col" v-show="!isSubmitApplyTable && !loading">
			<el-col :span="2">
				<el-button type="primary" @click="submit">提交</el-button>
			</el-col>
		</el-row>
		<!-- 关联对账函列表 -->
		<el-row>
			<el-col :span="23" class="checking-table">
				<label style="padding-top:10px;display:inline-block">关联对账函</label>
				<div class="opts-col" v-show="!isSubmitApplyTable">
					<a
						href="javasript:;"
						class="hit"
						style="margin-right:18px;"
						@click="addLetter"
						v-show="applyRowData.length == 0"
					>添加</a>
					<a href="javasript:;" class="hit" @click="delLetter">删除</a>
				</div>
				<ag-grid-vue
					class="ag-theme-balham ag-table"
					:gridOptions="applyGridOptions"
					:columnDefs="applyColumnDefs"
					:rowData="applyRowData"
					v-loading="applyLoading"
				></ag-grid-vue>
			</el-col>
		</el-row>
		<!-- 天进宝申请表 -->
		<el-row>
			<el-col :span="12">
				<el-form :v-model="applyShortTableForm" ref="applyShortTableForm">
					<el-form-item>
						<table class="emphasis-table">
							<tr>
								<th>流程编号：</th>
								<td class="hit font-underline">{{applyShortTableForm.item_no}}</td>
							</tr>
							<tr>
								<th>供应商名称：</th>
								<td>{{applyShortTableForm.cust_name}}</td>
							</tr>
							<tr>
								<th>实际控制人：</th>
								<td>{{applyShortTableForm.realController}}</td>
							</tr>
							<tr>
								<th>收款账户户名：</th>
								<td>{{name}}</td>
							</tr>
							<tr>
								<th>收款账户账号：</th>
								<td>{{bankNo}}</td>
							</tr>
							<tr>
								<th>收款账户开户行：</th>
								<td>{{bank}}</td>
							</tr>
							<tr>
								<th>微信：</th>
								<td>{{applyShortTableForm.custSrmWechat}}</td>
							</tr>
							<tr>
								<th>邮箱：</th>
								<td>{{applyShortTableForm.custSrmEmail}}</td>
							</tr>
							<tr>
								<th>融资金额：</th>
								<td>{{getFormatApplyAmt}} 元</td>
							</tr>
							<tr>
								<th>融资产品：</th>
								<td>{{applyShortTableForm.fin_type}}</td>
							</tr>
							<tr>
								<th>融资开始日期：</th>
								<td>{{applyShortTableForm.apply_date}}</td>
							</tr>
							<tr>
								<th>融资到期日期：</th>
								<td>{{applyShortTableForm.prepayback_date}}</td>
							</tr>
							<tr>
								<th>融资天数：</th>
								<td>{{getDayAmount}}</td>
							</tr>
							<tr>
								<th>服务费率（含税）：</th>
								<td>{{showRate}}</td>
							</tr>
							<tr>
								<th>预扣服务费（含税）：</th>
								<td>{{getPreDeductAmount}} 元</td>
							</tr>
							<tr>
								<th>到账金额：</th>
								<td>{{getArrivalAmount}} 元</td>
							</tr>
							<tr>
								<th>还款金额：</th>
								<td>{{getFormatApplyAmt}} 元</td>
							</tr>
							<tr>
								<th>金融客服：</th>
								<td>{{applyShortTableForm.apply_user}}</td>
							</tr>
							<tr>
								<th>客服电话：</th>
								<td>{{applyShortTableForm.apply_phone}}</td>
							</tr>
						</table>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>
		<el-row v-show="returnReason!=''">
			<el-col :span="23">
				<label style="color:red;">退回原因</label>
				<div class="returnReason">{{returnReason}}</div>
			</el-col>
		</el-row>
		<!-- 对账函列表 模态框 -->
		<el-dialog title="对账函列表" :visible.sync="assemblyModel" width="75%">
			<el-row :gutter="10" class="m-condition">
				<el-col :span="10">
					<el-input placeholder="输入对账函编号查询" v-model="searchValue"></el-input>
				</el-col>
				<el-col :span="3">
					<el-button type="primary" @click="searchLetter">搜索</el-button>
				</el-col>
			</el-row>
			<el-row>
				<el-col>
					<ag-grid-vue
						class="m-agTableModel ag-theme-balham"
						:gridOptions="checkingGridOptions"
						:columnDefs="checkingColumnDefs"
						:rowData="checkingRowData"
						v-loading="checkingLoading"
						overlayNoRowsTemplate="&nbsp;"
					></ag-grid-vue>

					<!-- <pagination :config="{pageNumberChanged2, pageSizeChanged2, pageNumber: applyShortTableForm.pageNumber}" :total="checkingTotal"></pagination> -->
				</el-col>
			</el-row>
			<el-row type="flex" justify="center">
				<el-col :span="4">
					<el-button type="primary" style="margin:20px 0;" @click="saveLetter">确认</el-button>
				</el-col>
			</el-row>
		</el-dialog>
	</div>
</template>
<style>
.msg-hint .el-message-box__message p {
	text-align: left !important;
	word-break: break-all;
}
</style>

<style lang="less" scoped>
.applyShortTable-col {
	height: 100%;
	padding-top: 50px !important;
	overflow-y: auto;
	overflow-x: hidden;
	&:after {
		display: block;
		height: 100px;
		content: "";
	}
	.returnReason {
		border: 1px solid #eee;
		padding: 5px;
		min-height: 100px;
		margin-top: 5px;
	}
	.footer-btns-col,
	.header-btns-col {
		position: fixed;
		height: 60px;
		width: 100%;
		bottom: 0;
		z-index: 10;
		margin-left: -10px !important;
		box-sizing: border-box;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #fff;
		padding: 10px 0;
		border-top: 1px solid #eee;
		/deep/ .el-button {
			margin-left: -84px;
		}
	}
	.header-btns-col {
		top: 0;
		justify-content: flex-start;
		border-top: none;
		border-bottom: 1px solid #eee;
		margin-top: 100px;
		/deep/ .el-button {
			margin-left: 8px;
		}
	}
	.hit {
		color: #409eff !important;
	}
	.emphasis-table {
		width: 100%;
		margin-top: 10px;
		.font-underline {
			text-decoration: underline;
		}
		tr {
			&:nth-child(even) th,
			&:nth-child(even) td {
				background: #f9fafa;
			}
			td,
			th {
				border: 1px solid #eee;
				padding: 0 10px;
				height: 35px;
				line-height: 35px;
				text-align: right;
				width: 50%;
			}
			td {
				text-align: left;
				& /deep/.el-input {
					.el-input__inner {
						border: none !important;
						outline-style: none !important;
						height: 35px;
						line-height: 35px;
						margin-left: -10px;
					}
					.el-input__icon {
						margin-left: -10px;
						margin-top: -5px;
					}
				}
			}
		}
	}
	.checking-table {
		margin-top: -10px;
		& label {
			font-size: 12px;
			font-weight: 600;
		}
		.ag-table {
			height: 200px;
			width: 100%;
			margin-top: 8px;
		}
		.opts-col {
            margin-top: 10px;
			float: right;
		}
	}
}
</style>
<script>
import Pagination from "@/components/pagination.vue";
import gridOptions from "lesso-common/public/gridOptions";
import signPreview from "@/components/SRM/pageComponents/signPreview";
import {
	formatRate,
	formatPrice,
	dateDiff,
	getSpecifyDate,
	numberMul,
	numberSub
} from "@/util/format.js";
import {
	mapState,
	mapActions
} from "vuex";
/**
 * @group financeManager
 * 提交天进宝融资
*/
export default {
    name:"applyShortTable",
	props: {
        // 申请id
		applyId: {
            type:String,
        },
        // 我的申请页跳转获得的申请Id
		applyListApplyId:{
            type:String,
        },
        // 当前流程节点
		currentAct: {
            type:String
        }
	},
	data () {
		return {
			isSearch: false,
			returnReason: '',
			loading: true,
			bankNo: '',
			bank: '',
			name: '',
			wfType: '', //流程类型，1：天进宝300万以下  2：天进宝300万以上
			applyIdFromCommit: '',
			fromPage: '',
			custInf: this.$store.state.supplyChainFinance.custInf, //获取供应商信息
			currentPage: 1,
			isSign: false,
			assemblyModel: false,
			listArray: [],
			applyShortTableForm: {
				id: "",
				item_no: "",
				cust_name: "",
				apply_amt: 0,
				fin_type: 0,
				apply_date: "",
				dayAmount: 0,
				service_rate: 0,
				preDeductAmount: 0,
				arrivalAmount: 0,
				apply_user: "",
				apply_phone: "",
				prepayback_date: "",
				custSrmEmail: "",
				custSrmWechat: "",
				realController: ''
			},
			// searchParams: {
			//   pageNumber: 1
			// },
			checkingTotal: 50,
			checkingGridOptions: {},
			checkingColumnDefs: [],
			checkingRowData: [],
			checkingLoading: false,
			applyTotal: 50,
			applyGridOptions: {},
			applyColumnDefs: [],
			applyRowData: [],
			applyLoading: false,
			pageListParams: {
				entity: {},
				current: 1,
				size: 10
			},
			searchValue: "",
		};
	},
	created () {
		let that = this
		document.onkeyup = function (e) {
			if (window.event) {
				e = window.event
			}
			var code = e.charCode || e.keyCode;
			if (code == 13) {
				that.searchLetter()
			}
		}
		this.getEsignAccountByCustId()
		this.applyGridOptions = gridOptions();
		this.checkingGridOptions = gridOptions();
		this.checkingColumnDefs = [{
			checkboxSelection: true, //是否显示复选框
			headerCheckboxSelection: true, //是否显示全选框
			headerName: "对账函编号",
			field: "accountCode",
			width: 205,
		},
		{
			headerName: "买方公司",
			field: "companyName",
			width: 180
		},
		{
			headerName: "商务合同名称及编号",
			field: "contractNo",
			width: 250,
			valueFormatter: params => {
				if (params.value) {
					return '《' + params.data.contractName + '》' + '（编号：' + params.value + '）'
				} else {
					return ''
				}
			}
		},
		{
			headerName: "对账函月份",
			field: "letterMonth",
			width: 100
		},
		{
			headerName: "应收金额",
			field: "payBalance",
			width: 110,
			valueFormatter: params => {
				return formatPrice(params.value)
			}
		},
		{
			headerName: "可融金额",
			field: "borrowBalance",
			width: 110,
			valueFormatter: params => {
				return formatPrice(params.value)
			}
		},
		{
			headerName: "已融资金额",
			field: "finAmount",
			width: 110,
			valueFormatter: params => {
				return formatPrice(params.value)
			}
		},
		{
			headerName: "融资状态",
			field: "finStatus",
			width: 100,
			cellRenderer: function (params) {
				if (params.value != undefined && params.value == 1) {
					return "部分融资";
				} else if (params.value == 2) {
					return "已融资";
				} else {
					return "未融资";
				}
			}
		}
		];
		this.applyColumnDefs = [{
			checkboxSelection: true, //是否显示复选框
			headerCheckboxSelection: true, //是否显示全选框
			headerName: "对账函编号",
			width: 205,
			field: "accountCode"
		},
		{
			headerName: "买方公司",
			field: "companyName",
			width: 180
		},
		{
			headerName: "商务合同名称及编号",
			field: "contractNo",
			width: 250,
			valueFormatter: params => {
				if (params.value) {
					return '《' + params.data.contractName + '》' + '（编号：' + params.value + '）'
				} else {
					return ''
				}
			}
		},
		{
			headerName: "对账函月份",
			field: "letterMonth",
			width: 120
		},
		{
			headerName: "应收金额",
			field: "payBalance",
			width: 150,
			valueFormatter: params => {
				return formatPrice(params.value)
			}
		},
		{
			headerName: "可融金额",
			field: "borrowBalance",
			width: 150,
			valueFormatter: params => {
				return formatPrice(params.value)
			}
		},
		{
			headerName: "已融资金额",
			field: "finAmount",
			width: 150,
			valueFormatter: params => {
				return formatPrice(numberSub(params.node.data.payBalance, params.node.data.borrowBalance))
			}
		},
		{
			headerName: "融资状态",
			field: "finStatus",
			width: 100,
			cellRenderer: function (params) {
				if (params.value != undefined && params.value == 1) {
					return "部分融资";
				} else if (params.value == 2) {
					return "已融资";
				} else {
					return "未融资";
				}
			}
		}
		];
		if (this.currentAct == '联塑金融审批') {
			this.pageListParams.entity.applyId = this.applyListApplyId;
			this.getPageLetterlist(this.pageListParams)
		}
	},
	beforeMount () {
		let that = this;
		this.fromPage = this.supplierApplyList.fromPage;
		let applyMainId = ""; //申请主表id
		if (this.fromPage == "applyShortPreview") {
			//从确认融资页面跳转
			applyMainId = that.applyId;
		} else if (this.fromPage == "applyList") {
			//从申请列表跳转
			applyMainId = that.applyListApplyId;
		}
		// applyMainId = that.applyId || that.applyListApplyId
		if (this.currentAct == '已退回') {
			this.getRefusedActivity(applyMainId)
		}
		if (applyMainId) {
			//获取申请主表信息
			that.$http.getApplyInfo({
				id: applyMainId
			}).then(response => {
				setTimeout(() => {
					that.loading = false
				}, 500)
				if (response.data.code == 200) {
					let data = response.data.rows;
					if (data.processStatus == 0) {
						this.wfType = 1 //天进宝300万以下
					} else {
						this.wfType = 2 //天进宝300万以上
					}
					that.applyShortTableForm.id = data.id
					that.applyShortTableForm.item_no = data.itemNo
					that.applyShortTableForm.cust_name = data.custName
					that.applyShortTableForm.apply_amt = data.applyAmt ? data.applyAmt : 0
					that.applyShortTableForm.fin_type = data.finType == 0 ? "天进宝" : "月有钱"
					that.applyShortTableForm.service_rate = data.serviceRate ? data.serviceRate : 0
					that.applyShortTableForm.apply_user = data.applyUser
					that.applyShortTableForm.apply_phone = data.applyPhone
					that.applyShortTableForm.prepayback_date = data.prepaybackDate ? data.prepaybackDate.substring(0, 10) : ''
					that.applyShortTableForm.apply_date = data.applyDate ? data.applyDate.substring(0, 10) : ''
					that.applyShortTableForm.custSrmEmail = data.custSrmEmail
					that.applyShortTableForm.custSrmWechat = data.custSrmWechat
					that.applyShortTableForm.realController = data.realController
				} else {
					this.$alert("获取申请表信息失败", {
						confirmButtonText: "确定",
						customClass: "alertFailure"
					});
				}
			})
				.catch(errror => {
					this.loading = false
					this.$alert("查询主表信息失败，请检查网络", {
						confirmButtonText: "确定",
						customClass: "alertFailure"
					})
				});
		}
	},
	methods: {
		...mapActions(["changeTOdo", "changePageCode"]),
        ...mapActions(["changeFromPage"]),
        /**
         * @vuese
         * 获取退回信息
         * @arg 参数applyId为当前申请单Id
        */
		async getRefusedActivity (applyId) {
			await this.$http.getRefusedActivity({
				applyId: applyId
			}).then(({ data }) => {
				if (data.code == 200 && data.rows) {
					this.returnReason = data.rows.note || ''
				}
			}).catch(error => {
				this.$alert("查询退回信息数据失败，请检查网络！", {
					confirmButtonText: "确定",
					customClass: "alertFailure"
				})
			})
        },
        /**
         * @vuese
         * 获取当前供应商电子签账号信息
        */
		async getEsignAccountByCustId () {
			let custId = this.supplyChainFinance.custInf.custId + ""
			let that = this
			await this.$http.getEsignAccountByCustId({
				custId: custId
			}).then(({
				data
			}) => {
				if (data.code == 200 && data.rows) {
					that.bankNo = data.rows.bank_no
					var bankinfo = data.rows.sub_bank
					bankinfo = bankinfo.replace(data.rows.bank, '')
					bankinfo = data.rows.bank + bankinfo
					that.bank = bankinfo
					that.name = data.rows.name
				} else {
					this.$alert(`获取数据失败：${data.info}`, {
						confirmButtonText: "确定",
						customClass: "alertFailure"
					})
				}
			}).catch(error => {
				this.$alert('查询失败，请检查网络！', {
					confirmButtonText: "确定",
					customClass: "alertFailure"
				})
			})
        },
        /**
         * @vuese
         * 点击返回按钮回调
        */
		goBack () {
			if (this.fromPage == "applyShortPreview") {
				//从确认融资页面跳转
				this.$emit("showShotPreview", this.applyId);
			} else if (this.fromPage == "applyList") {
				//从申请列表跳转
				this.changePageCode('')
			}
			this.listArray = [];
        },
        /**
         * @vuese
         * 提交天进宝融资申请
        */
		submit () {
			let that = this;
			let params = new Object();
			let loading;
			params = {
				applyId: that.applyShortTableForm.id,
				entityList: that.applyRowData
			};
			if (params.entityList.length == 0) {
				this.$alert("请添加对账函", {
					confirmButtonText: "确定",
					customClass: "alertPrompt"
				});
				return
			}
			this.$confirm('确认是否提交申请表?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消'
			}).then(() => {
				loading = this.$loading({
					lock: true,
					text: '融资申请提交中，请稍等',
					spinner: 'el-icon-loading',
					background: 'rgba(255,255,255,.9)'
				})
				params.id = that.applyShortTableForm.id
				that.$http.submitApply(params).then(response1 => {
					loading.close()
					if (response1.data.code == 200) {
						this.$alert("融资申请提交成功", {
							confirmButtonText: "确定",
							customClass: "alertSuccess"
						});
						if (that.wfType == 1) {
							that.isSign = true;
						} else {
							that.changePageCode('')
						}
						that.applyIdFromCommit = that.applyShortTableForm.id;
						that.listArray = [];
					} else {
						this.$alert("融资申请提交失败:" + response1.data.info, {
							confirmButtonText: "确定",
							customClass: "alertFailure"
						});
					}
				}).catch(errror => {
					loading.close()
					this.$alert("融资申请提交失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure"
					});
				})
			}).catch(() => { })
			// that.$http
			//   .saveBatchApplyLetter(params)
			//   .then(response => {
			//     if (response.data.code == 200) {
			//       params = new Object();


			//     } else {
			//       that.showSignloading = false
			//       that.$message.error('保存对账函明细失败:'+ response.data.info);
			//     }
			//   })
			//   .catch(errror => {
			//     that.showSignloading = false
			//     that.$alert("保存对账函明细失败，请检查网络！", {
			//       confirmButtonText: "确定",
			//       customClass: "alertFailure"
			//     });
			//   });
		},
        /**
         * @vuese
         * 添加关联对账函,打开选择对账函弹窗
        */
		addLetter () {
			this.assemblyModel = true;
			this.searchValue = ''
			this.isSearch = false
			this.getApplyLetterList({
				supplierId: this.custInf.custId,
				actBalance: this.applyShortTableForm.apply_amt,
				param: "",
			});
		},
        /**
         * @vuese
         * 添加对账函弹窗搜索对账函
        */
		searchLetter () {
			let params = {
				supplierId: this.custInf.custId,
				param: this.searchValue,
				actBalance: this.applyShortTableForm.apply_amt
			}
			this.isSearch = true
			this.getApplyLetterList(params);
		},
        /**
         * @vuese
         * 删除已关联对账函
        */
		delLetter () {
			let selectRows = this.applyGridOptions.api.getSelectedRows();
			if (selectRows.length == 0) {
				this.$alert("请选择对账函进行删除", {
					confirmButtonText: "确定",
					customClass: "alertPrompt"
				});
				return
			}
			let originRows = this.applyRowData;
			this.applyRowData = this.delSelectRows(selectRows, originRows);
		},
        /**
         * @vuese
         * 确认保存已选择的对账函
        */
		saveLetter () {
			let selectRows = this.checkingGridOptions.api.getSelectedRows();
			if (selectRows <= 0) {
				this.$alert("请选择对账函进行保存", {
					confirmButtonText: "确定",
					customClass: "alertPrompt"
				});
				return
			}
			let letterArr = []
			//系统自动分配的对账函
			let letters = []
			let ishint = false
			//对账函可融金额总数
			let letterMoney = 0
			//融资金额
			let money = this.applyShortTableForm.apply_amt
			for (let i = 0; i < selectRows.length; i++) {
				if (money > letterMoney) {
					letterMoney += selectRows[i].borrowBalance
					letterArr.push(selectRows[i].accountCode)
					letters.push(selectRows[i])
				} else {
					ishint = true
					break
				}
			}
			if (money > letterMoney) {
				this.$alert("您选择的对账函可融金额小于申请融资金额，请继续添加对账函", {
					confirmButtonText: "确定",
					customClass: "alertPrompt"
				});
				return
			}
			if (ishint) {
				this.$confirm(`经系统计算，您选择的对账函中只需选择 ${letterArr.join('、')} 即可满足当前融资需求，同意系统自动分配,请点击“确认”，如需重新选择，请点击“取消”`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
					customClass: 'msg-hint',
					center: false
				}).then(() => {
					this.listArray = this.applyRowData.concat(letters); //数组合并
					this.applyRowData = this.unique(this.listArray);
					this.checkingRowData = []; //清空弹窗数据
					this.assemblyModel = false;
				}).catch(() => { })
			} else {
				this.listArray = this.applyRowData.concat(letters); //数组合并
				this.applyRowData = this.unique(this.listArray);
				this.checkingRowData = []; //清空弹窗数据
				this.assemblyModel = false;
			}
		},
        /**
         * @vuese
         * 获取实时对账函列表数据
         * @arg 参数params为Obj;代表接口请求参数
        */
		getApplyLetterList (params) {
			let that = this;
			that.checkingLoading = true
			that.checkingRowData = [];
			that.checkingGridOptions.overlayNoRowsTemplate = '&nbsp;'
			setTimeout(function () {
				that.$http.getApplyLetterList(params).then(response => {
					that.checkingLoading = false;
					if (response.data.code == 200) {
						let rowDatas = response.data.rows;
						rowDatas.forEach(element => {
							element.letterNo = element.accountNo; //对账函编号
							element.letterId = element.id; //对账函id
							element.letterMonth = element.yMonth; //对账函月份
							element.letterUrl = element.url; //对账函月份
						});
						that.checkingRowData = rowDatas;
						if (that.isSearch && that.checkingRowData.length == 0) {
							that.checkingGridOptions.overlayNoRowsTemplate = '未搜索到匹配结果'
						}
					} else {
						that.checkingRowData = [];
						if (that.isSearch) {
							that.checkingGridOptions.overlayNoRowsTemplate = '未搜索到匹配结果'
						}
					}
				})
					.catch(errror => {
						that.$alert("查询对账列表失败，请检查网络！", {
							confirmButtonText: "确定",
							customClass: "alertFailure"
						});
					});
			}, 500);
		},
        /**
         * @vuese
         * 删除对账函明细DOM
         * @arg 参数selectArrayData为需要删除的行;originArrayData为所有已关联的对账函
        */
		delSelectRows (selectArrayData, originArrayData) {
			for (var i = 0; i < selectArrayData.length; i++) {
				originArrayData.splice(originArrayData.indexOf(selectArrayData[i]), 1);
			}
			return originArrayData;
		},
		/**
         * @vuese
         * 数组去重
         * @arg 参数objArray为需要去重的数组
        */
		unique (objArray) {
			var result = [];
			var temp = {};
			for (var i = 0; i < objArray.length; i++) {
				var myid = objArray[i].id;
				if (temp[myid]) {
					continue;
				}
				temp[myid] = true;
				result.push(objArray[i]);
			}
			return result;
		},
        /**
         * @vuese
         * 查询可关联对账函数据
         * @arg 参数params为Obj;代表接口请求参数
        */
		getPageLetterlist (params) {
			this.$http
				.getApplyLetter(params)
				.then(response => {
					if (response.data.code == 200) {
						let rowDatas = response.data.rows
						rowDatas.forEach(element => {
							element.accountNo = element.letterNo //对账函编号
							element.accountNo = element.letterNo //对账函编号
						})
						this.applyRowData = rowDatas;
					} else {
						this.applyRowData = []
						this.$alert(response.data.info, {
							confirmButtonText: "确定",
							customClass: "alertFailure"
						});
					}
				})
				.catch(errror => {
					this.$alert("获取对账函信息失败，请检查网络！", {
						confirmButtonText: "确定",
						customClass: "alertFailure"
					});
					this.applyRowData = []
				});
		},
	},
	computed: {
		...mapState(['supplyChainFinance', 'supplierApplyList']),
		//显示服务费率
		showRate () {
			return formatRate(this.applyShortTableForm.service_rate) + "/天";
		},
		//获取预扣金额
		getPreDeductAmount () {
			this.applyShortTableForm.preDeductAmount = numberMul(numberMul(this.applyShortTableForm.apply_amt, this.applyShortTableForm
				.service_rate), this.applyShortTableForm.dayAmount).toFixed(2)
			return formatPrice(this.applyShortTableForm.preDeductAmount);
		},
		getArrivalAmount () {
			this.applyShortTableForm.arrivalAmount = numberSub(this.applyShortTableForm.apply_amt, this.applyShortTableForm
				.preDeductAmount).toFixed(2)
			return formatPrice(this.applyShortTableForm.arrivalAmount);
		},
		getDayAmount () {
			this.applyShortTableForm.dayAmount = dateDiff(
				this.applyShortTableForm.apply_date,
				this.applyShortTableForm.prepayback_date
			);
			return this.applyShortTableForm.dayAmount + "天";
		},
		//获取融资到期日
		getPaybackDate () {
			return getSpecifyDate(25);
		},
		isSubmitApplyTable () {
			return this.currentAct == '联塑金融审批' || this.currentAct == '已完成' || this.currentAct == '已退回' || this.currentAct == '已撤销'
		},
		getFormatApplyAmt () {
			return formatPrice(this.applyShortTableForm.apply_amt)
		}
	},
	components: {
		Pagination,
		signPreview
	}
};
</script>